Skip to content

Build / security fixes, Prisma updates to run migrations on deploy, and add new subcontractingEndCustomer field to billing accounts to be loaded from Salesforce.#6

Merged
jmgasper merged 15 commits into
masterfrom
develop
Dec 4, 2025
Merged

Build / security fixes, Prisma updates to run migrations on deploy, and add new subcontractingEndCustomer field to billing accounts to be loaded from Salesforce.#6
jmgasper merged 15 commits into
masterfrom
develop

Conversation

@jmgasper

@jmgasper jmgasper commented Dec 4, 2025

Copy link
Copy Markdown
Contributor

No description provided.

@github-advanced-security

Copy link
Copy Markdown

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

@jmgasper
jmgasper merged commit 18e539d into master Dec 4, 2025
5 of 6 checks passed
Comment thread Dockerfile
# ---- Base Stage ----
FROM node:20-alpine AS base
FROM node:22.19-alpine AS base
RUN apk add --no-cache openssh-client git openssl

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ security]
Consider verifying whether all added packages (openssh-client, git, openssl) are necessary for the production environment. Unnecessary packages can increase the image size and potentially introduce security vulnerabilities.

Comment thread Dockerfile

# Expose the application port
EXPOSE 3000
RUN chmod +x /entrypoint.sh

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[❗❗ security]
Ensure that the entrypoint.sh script is securely handling inputs and does not introduce security vulnerabilities. It's crucial to validate and sanitize any inputs it processes.

Comment thread entrypoint.sh
@@ -0,0 +1,25 @@
#!/bin/sh

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[💡 maintainability]
Consider using #!/bin/bash instead of #!/bin/sh for better compatibility and feature support, especially if any bash-specific features are needed in the future.

Comment thread entrypoint.sh

echo "Running database migrations..."

npx prisma migrate deploy

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ maintainability]
Consider adding error handling for the npx prisma migrate deploy command. While set -e will exit on error, providing a more descriptive error message or logging could improve debugging.

@@ -0,0 +1,2 @@
-- Add subcontracting end customer column
ALTER TABLE "BillingAccount" ADD COLUMN "subcontractingEndCustomer" VARCHAR(255);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ correctness]
Consider adding a NOT NULL constraint or a default value if this column is expected to always have a value. This can prevent potential issues with null values in the application logic.


for (const file of files) {
const abs = path.resolve(process.cwd(), file);
if (!fs.existsSync(abs)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ performance]
Using fs.existsSync is generally discouraged in asynchronous code as it introduces a race condition. Consider using fs.promises.access for a non-blocking check.

continue;
}

await prisma.billingAccount.update({

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ correctness]
Consider using a transaction for the update operation to ensure atomicity and consistency, especially if there are multiple updates that need to be treated as a single unit of work.

await prisma.$disconnect();
}

main().catch(async (err) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[💡 maintainability]
Consider logging the error with more context or using a logging library to capture stack traces and additional metadata for better debugging.

Comment thread scripts/import-markup.ts

const DEFAULT_JSON_PATH = '/mnt/export/time_oltp:project_contest_fee_percentage_1.json';

function toDecimalOrNull(v: ContestFeeRow['contest_fee_percentage']): Prisma.Decimal | null {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ correctness]
Consider validating the input more rigorously before attempting to convert it to a Prisma.Decimal. This could prevent unexpected errors if the input is not a valid number format.

Comment thread scripts/import-markup.ts
if (!fs.existsSync(filePath)) {
throw new Error(`Input file not found: ${filePath}`);
}
const raw = fs.readFileSync(filePath, 'utf8');

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ performance]
Reading the entire file into memory with fs.readFileSync can be problematic for very large files. Consider using a streaming approach if you expect large input files.

Comment thread scripts/import-markup.ts
const rows = readContestFees(inputPath);
console.log(`Parsed ${rows.length} record(s).`);

const prisma = new PrismaClient();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[❗❗ maintainability]
Ensure that the PrismaClient instance is properly closed in all scenarios, including when an error occurs before reaching the end of the main function. Consider using a finally block or similar mechanism to guarantee disconnection.

Comment thread scripts/import-markup.ts
continue;
}

try {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ performance]
The await inside the loop can lead to performance issues due to sequential execution. Consider using Promise.all to perform updates concurrently, if the database can handle it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants